package main

import (
	"errors"
	"fmt"
	"time"
)

func main() {

	go func() {
		defer func() {
			if err := recover(); err != nil { //产生了panic异常
				fmt.Println("hello")
				fmt.Println(err)
			}
		}()
		i := 0
		for i < 10 {
			i++
			fmt.Println("tick...")
			time.Sleep(time.Second)
			if i == 5 {
				panic(errors.New("just error occurred"))
			}
		}
	}()

	time.Sleep(time.Hour)
}
